package com.itboye.eweilisten.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.itboye.eweilisten.R;
import com.itboye.eweilisten.model.SouSuoBean;

import java.util.List;

/**
 * Created by itboye on 2017/4/14.
 */

public class AA extends BaseAdapter{
    List<SouSuoBean> been;
    Context context;
    int num;
    private int clickTemp = -1;
    public AA ( List<SouSuoBean> been, Context context){
        this.been=been;
        this.context=context;
    }
    @Override
    public int getCount() {
        for (int i=0;i<been.size();i++){
            num=been.get(i).getUnits().size();
        }
        return num;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
    public void setSeclection(int position) {
        clickTemp = position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHouder houder=null;
        if(convertView==null){
            houder=new ViewHouder();
            convertView= LayoutInflater.from(context).inflate(R.layout.aa,null);
            houder.textView4= (TextView) convertView.findViewById(R.id.textGridview);
            houder.imageView2= (ImageView) convertView.findViewById(R.id.imageView2);
            houder.longriview= (RelativeLayout) convertView.findViewById(R.id.longriview);
            convertView.setTag(houder);
        }else{
            houder= (ViewHouder) convertView.getTag();
        }

        for (int j=0;j<been.size();j++) {
            if (been.get(j).isSelect()){
                Log.d("tempItemtempItem",been.get(j).isSelect()+"");
                houder.longriview.setBackgroundResource(R.drawable.chengji_yessow);
                houder.imageView2.setVisibility(View.VISIBLE);
            } else {
                houder.imageView2.setVisibility(View.GONE);
                houder.longriview.setBackgroundResource(R.drawable.delete_flow_dre);
            }
            houder.textView4.setText(been.get(j).getUnits().get(position).getUnit_name());
        }
        return convertView;
    }
    public class ViewHouder{

        private TextView textView4;
        ImageView imageView2;
        RelativeLayout longriview;

    }
}
